<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">

    <title>供应商管理</title>
    <!-- <link href="lib/css/meterial_icons.css" rel="stylesheet" type="text/css"> -->
    <link href="../lib/fonts/material-icons.css?family=Material+Icons" rel="stylesheet">
    <link href="../lib/css/animate.min.css" rel="stylesheet">
    <link href="../lib/css/quasar.mat.rtl.min.css" rel="stylesheet" type="text/css">

    <style type="text/css">
      [v-cloak] { display: none }
      .bd-light { border: 1px solid rgba(0, 0, 0, .1) }
      div.q-if-inner div.q-input-target {line-height: 24px}  /* 兼容 ie 的 */
    </style>
  </head>
  <body>
    <div id="q-supplierManage" v-cloak class="q-pa-sm">
      <q-card class="bg-white no-shadow full-width">
        <q-card-main class="relative-position">
          <q-tabs 
            v-model="selectedTab" 
            color="secondary"
            inverted 
            @select="getList({pagination: serverPagination})"
          >
            <q-tab 
              style="width:100px" 
              v-for="(item, index) in tabData" 
              :default="index == 0? true: false" 
              slot="title" 
              :name="item.id" 
              :label="item.name"></q-tab>
          </q-tabs>
          <div class="row justify-between gutter-x-sm gutter-y-xs q-mt-md">
            <q-field class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
              <q-input
                :float-label="$t('供应商名称')"
                v-model.trim="searchForm.search_LIKE_name"></q-input>
            </q-field>
            <q-field class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
              <q-input
                :float-label="$t('供应商编码')"
                v-model.trim="searchForm.search_LIKE_code"></q-input>
            </q-field>
            <q-field class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
              <q-input
                :float-label="$t('企业法人')"
                v-model.trim="searchForm.search_LIKE_legalPerson"></q-input>
            </q-field>
            <q-slide-transition>
              <q-field v-if="isShowMoreSearch" class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                <q-input
                  :float-label="$t('供应商性质')"
                  v-model.trim="searchForm.search_LIKE_property"></q-input>
              </q-field>
            </q-slide-transition>
          </div>
          <div class="row justify-end q-my-sm">
            <q-btn
              size="sm"
              @click="getList({pagination: serverPagination})"
              color="primary"
              class="q-mt-sm q-mr-sm q-pa-sm">
              <q-icon name="search"></q-icon>
              <span>{{ $t('查询') }}</span>
            </q-btn>
            <q-btn
              size="sm"
              color="secondary"
              @click="reset"
              class="q-mt-sm q-mr-sm q-pa-sm">
              <q-icon name="refresh" ></q-icon>
              <span>{{ $t('重置') }}</span>
            </q-btn>
            <q-btn
              flat
              size="sm"
              class="q-mt-sm q-mr-xs q-pa-sm"
              color="primary"
              @click="toggleShowMoreSearch">
              <span v-if="isShowMoreSearch">{{ $t('收起') }}</span>
              <span v-else>{{ $t('展开') }}</span>
              <q-icon v-if="isShowMoreSearch" name="keyboard arrow up" ></q-icon>
              <q-icon v-else name="keyboard arrow down" ></q-icon>
            </q-btn>
          </div>
          <q-table
            class="no-shadow"
            :data="data"
            :columns="columns"
            :visible-columns="visibleColumns"
            :rows-per-page-options="[5, 10, 20]"
            selection="multiple"
            :loading = "listLoading"
            :selected.sync="selected"
            :pagination.sync="serverPagination"
            @request="getList"
            row-key="id"
          >
            <div slot="pagination" slot-scope="props" class="row flex-center q-py-sm">
              第
              <q-pagination
                v-model="serverPagination.page"
                input
                boundary-links
                direction-links
                color="secondary"
                :max-pages="5"
                :ellipses="true"
                :max="pages"></q-pagination>
              页 &nbsp; 共 {{ total }} 条
            </div>
            <template slot="top-left" slot-scope="props">
              <q-btn
                color="secondary"
                flat
                @click="startSupplier"
                :label="$t('启用')"
                class="q-mr-sm" ></q-btn>
              <q-btn
                color="negative"
                flat
                :label="$t('禁用')"
                @click="stopSupplier"></q-btn>
              <q-btn
                color="secondary"
                flat
                v-if="selectedTab == 17994400 && buttonStatus == 1"
                @click="requestSupplierCode"
                :label="$t('申请正式编码')"
                class="q-mr-sm" ></q-btn>
              <q-btn
                color="secondary"
                flat
                v-if="selectedTab == 17994400 && buttonStatus3 == 1"
                @click="requestSupplierCodeFrom"
                :label="$t('申请正式编码')"
                class="q-mr-sm" ></q-btn>
              <q-btn
                color="secondary"
                flat
                v-if="selectedTab == 17994403 && buttonStatus2 == 1"
                @click="supplierDispatch"
                :label="$t('下发其他系统')"
                class="q-mr-sm" ></q-btn>
            </template>
            <template slot="body" slot-scope="props">
              <q-tr
                :props="props"
              >
                <q-td >
                  <q-checkbox color="primary" v-model="props.selected"></q-checkbox>
                </q-td>
                <q-td
                  key="code"
                  :props="props">
                  <q-btn 
                    flat 
                    color="primary" 
                    class="q-pa-none" 
                    @click="goSupplierBaseInfoLook(props.row.orgId, props.row.id)">
                    {{ props.row.code }}
                  </q-btn>
                  <q-chip square dense small color="light" v-if="props.row.codeStatus === 1">非正式</q-chip>
                  <q-chip square dense small color="info" v-else-if="props.row.codeStatus === 2">正式</q-chip>
                  <q-chip square dense small color="secondary" v-else-if="props.row.codeStatus === 3">待审核</q-chip>
                  <q-chip square dense small color="positive" v-else-if="props.row.codeStatus === 4">审核通过
                    <q-tooltip self="bottom left">通过原因：{{ props.row }}</q-tooltip>
                  </q-chip>
                  <q-chip square dense small color="negative" v-else-if="props.row.codeStatus === 5">审核驳回
                    <q-tooltip self="bottom left">驳回原因：{{ props.row }}</q-tooltip>
                  </q-chip>
                  <q-chip square dense small color="warning" v-else>获取状态失败</q-chip>
                </q-td>
                <q-td
                  key="name"
                  :props="props">{{ props.row.name }}</q-td>
                <q-td
                  key="enableStatus"
                  :props="props">
                  <span v-if="props.row.vendor">
                      <q-chip square dense small color="positive" v-if="props.row.vendor.enableStatus == 1">已启用</q-chip>
                      <q-chip square dense small color="negative" v-if="props.row.vendor.enableStatus == 0">已禁用</q-chip>
                  </span>
                </q-td>
                <q-td
                  key="submitStatus"
                  :props="props">
                  {{ props.row.submitStatus == 1? '已提交': '' }}
                </q-td>
                <q-td
                  key="promotableStatus"
                  :props="props">
                  <span v-if="props.row.promotableStatus">
                      <q-chip square dense small color="light" v-if="props.row.promotableStatus == -1">未提交</q-chip>
                      <q-chip square dense small color="info" v-if="props.row.promotableStatus == 0">未审核（已提交）</q-chip>
                      <q-chip square dense small color="positive" v-if="props.row.promotableStatus == 1">通过</q-chip>
                      <q-chip square dense small color="negative" v-if="props.row.promotableStatus == 2">不通过</q-chip>
                  </span>
                </q-td>
                <q-td
                  key="degradableStatus"
                  :props="props">
                  <span v-if="props.row.degradableStatus">
                      <q-chip square dense small color="light" v-if="props.row.degradableStatus == -1">未提交</q-chip>
                      <q-chip square dense small color="info" v-if="props.row.degradableStatus == 0">未审核（已提交）</q-chip>
                      <q-chip square dense small color="positive" v-if="props.row.degradableStatus == 1">通过</q-chip>
                      <q-chip square dense small color="negative" v-if="props.row.degradableStatus == 2">不通过</q-chip>
                  </span>
                </q-td>
                <q-td
                  key="property"
                  :props="props">{{ props.row.property == 1? '国有企业': (props.row.property == 2? '国有控股企业': (props.row.property == 3? '外资企业': (props.row.property == 4? '合资企业': (props.row.property == 5? '私营企业': ''))))  }}</q-td>
                <q-td
                  key="legalPerson"
                  :props="props">{{ props.row.legalPerson }}</q-td>
                <q-td
                  key="countryText"
                  :props="props">{{ props.row.countryText }}</q-td>
                <q-td
                  key="provinceText"
                  :props="props">{{ props.row.provinceText }}</q-td>
                <q-td
                  key="cityText"
                  :props="props">{{ props.row.cityText }}</q-td>
              </q-tr>
              <!-- 展开行 -->
            </template>
          </q-table>
        </q-card-main>
      </q-card>
      <q-modal no-backdrop-dismiss v-model="requestSupplierCodeModal" :content-css="{minWidth: '36vw', minHeight: '450px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              {{ $t("申请编码") }}
            </q-toolbar-title>
            <q-btn flat @click="requestSupplierCodeModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <q-card-main class="row gutter-x-md gutter-y-sm">
              <q-field 
                :error="$v.requestSupplierCodeForm.subjectGroupId.$error"
                error-label="科目组为必选项"
                class="col-12">
                <q-select
                  :options="subjectGroupOptions"
                  :float-label="$t('科目组')"
                  @input="getCodeRuleData"
                  @blur="$v.requestSupplierCodeForm.subjectGroupId.$touch"
                  v-model="requestSupplierCodeForm.subjectGroupId"></q-select>
              </q-field>
              <q-field 
                :error="$v.requestSupplierCodeForm.codeRule.$error"
                error-label="编码生成规则为必选项"
                class="col-12">
                <q-select
                  :options="codeRuleOptions" 
                  :float-label="$t('编码生成规则')"
                  @blur="$v.requestSupplierCodeForm.codeRule.$touch"
                  v-model="requestSupplierCodeForm.codeRule"></q-select>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              flat
              color="primary"
              @click="requestSupplierCodeModal = false">{{$t("取消")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              @click="saveRequestHandler">{{$t("保存")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
    </div>
    <!-- ie-polyfill 、 vue.js and quasar-framework -->
    <script src="../lib/js/quasar.ie.polyfills.umd.min.js"></script>
    <script src="../lib/js/vue.js"></script>
    <script src="../lib/js/quasar.mat.umd.min.js"></script>
    <!-- babel for es6 transform -->
    <!-- <script src="lib/js/babel.min.js"></script> -->
    <!-- vue validate -->
    <script src="../lib/js/vuelidate.min.js"></script>
    <script src="../lib/js/validators.min.js"></script>
    <!-- consts ps: always leave this file first -->
    <script src="../script/consts.js"></script>
    <!-- status code -->
    <script src="../script/status.code.js"></script>
    <!-- qs for axios -->
    <script src="../lib/js/qs.min.js"></script>
    <!-- axios for http request -->
    <script src="../lib/js/axios.js"></script>
    <!-- axios.instance must be after axios -->
    <script src="../script/axios.instance.js"></script>
    <!-- quasar i18n zh-hans -->
    <script src="../lib/lang/zh-hans.js"></script>
    <!-- vue-i18n for application's internationalization -->
    <script src="../lib/js/vue-i18n.js"></script>
    <!-- current page international file -->
    <script src="../lang/sop/supplierManage.js"></script>
    <script>
      // quasar components use
      Quasar.i18n.set(Quasar.i18n[LANGUGE])

      Vue.use(window.vuelidate.default)
      var minLength = window.validators.minLength
      var required = window.validators.required
      var email = window.validators.email

      var supplierManage = new Vue({
        el: '#q-supplierManage',
        i18n: i18n,
        data: function () {
          return {
            // search
            searchForm: {
              search_LIKE_name: '',
              search_LIKE_code: '',
              search_LIKE_legalPerson: '',
              search_LIKE_property: ''
            },
            isShowMoreSearch: false,
            // tab
            tabData: [],
            selectedTab: '',
            // table
            listLoading: false,
            btnLoading: false,
            selected: [],
            data: [],
            total: 0,
            // 按钮权限
            buttonStatus: '0',  // SRM自动生成 1 显示 0 不显示
            buttonStatus2: '0',  // 下发其他系统
            buttonStatus3: '0',  // 获取其他系统正式编码
            // 申请供应商编码
            requestSupplierCodeModal: false,
            requestSupplierCodeForm: {
              subjectGroupId: '',
              codeRule: ''
            },
            subjectGroupOptions: [],
            codeRuleOptions: [],
            // 分页
            serverPagination: {
              page: 1,
              rowsNumber: 5,
              rowsPerPage: 5
            },
            visibleColumns: [
              'name',
              'code',
              'enableStatus',
              'submitStatus',
              'promotableStatus',
              'degradableStatus',
              'property',
              'legalPerson',
              'countryText',
              'provinceText',
              'cityText'
            ]
          }
        },
        validations: {
          addOrEditForm: {
            vendorName: { required: required },
            vendorEmail: { required: required, email: email },
            contactPeople: { required: required },
            remarks: { required: required }
          },
          requestSupplierCodeForm: {
            subjectGroupId: { required: required },
            codeRule: { required: required }
          }
        },
        computed: {
          // 表格配置
          columns: function() {
            return [
              {
                name: 'code',
                label: this.$t('供应商编码'),
                align: 'left',
                field: 'code',
                sortable: true
              },
              {
                name: 'name',
                label: this.$t('供应商名称'),
                align: 'left',
                field: 'name',
                sortable: true
              },
              {
                name: 'enableStatus',
                label: this.$t('启用状态'),
                align: 'left',
                field: 'enableStatus',
                sortable: true
              },
              {
                name: 'submitStatus',
                label: this.$t('提交状态'),
                align: 'left',
                field: 'submitStatus',
                sortable: true
              },
              {
                name: 'promotableStatus',
                label: this.$t('晋级审批'),
                align: 'left',
                field: 'promotableStatus',
                sortable: true
              },
              {
                name: 'degradableStatus',
                label: this.$t('降级状态'),
                align: 'left',
                field: 'degradableStatus',
                sortable: true
              },
              {
                name: 'property',
                label: this.$t('供应商性质'),
                align: 'left',
                field: 'property',
              },
              {
                name: 'legalPerson',
                label: this.$t('企业法人'),
                align: 'left',
                field: 'legalPerson'
              },
              {
                name: 'countryText',
                label: this.$t('国家名称'),
                align: 'left',
                field: 'countryText',
                sortable: true
              },
              {
                name: 'provinceText',
                label: this.$t('省份名称'),
                align: 'left',
                field: 'provinceText',
                sortable: true
              },
              {
                name: 'cityText',
                label: this.$t('城市名称'),
                align: 'left',
                field: 'cityText',
                sortable: true
              }
            ]
          },
          pages: function() {
            return Math.ceil(this.total / this.serverPagination.rowsPerPage)
          }
        },
        created: function () {
          this.getTabData()
          this.getSubjectGroupData()
        },
        watch: {
          'serverPagination.page': function (page) {
            this.getList({
              pagination: this.serverPagination
            }, this.selectedTab)
          },
          'serverPagination.rowsPerPage': function (rowsPerPage) {
            this.getList({
              pagination: this.serverPagination
            }, this.selectedTab)
          },
        },
        methods: {
          // Tab 的
          getTabData: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/new/stage/getall',
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.tabData = data.rows
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
            })
            .catch(function(err) {
              console.log(err, '获取Tab数据时捕获异常');
            })
          },
          getList: function(arg) {
            this.listLoading = true
            this.serverPagination = arg.pagination
            var that = this
            axios({
              method: 'post',
              url: '/manager/new/vendor/baseInfoNew/query?search_EQ_phaseId=' + this.selectedTab,
              data: {
                page: this.serverPagination.page,
                rows: this.serverPagination.rowsPerPage,
                sort: this.serverPagination.sortBy,
                order: this.serverPagination.descending == true? 'desc' : (this.serverPagination.descending == false? 'asc' : ''),
                search_LIKE_name: this.searchForm.search_LIKE_name,
                search_LIKE_code: this.searchForm.search_LIKE_code,
                search_LIKE_legalPerson: this.searchForm.search_LIKE_legalPerson,
                search_LIKE_property: this.searchForm.search_LIKE_property
              }
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.data = data.rows
                that.total = data.total
                that.buttonStatus = data.buttonStatus
                that.buttonStatus2 = data.buttonStatus2
                that.buttonStatus3 = data.buttonStatus3
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
              that.listLoading = false
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          toggleShowMoreSearch: function () {
            this.isShowMoreSearch = !this.isShowMoreSearch
          },
          // 重置
          reset: function () {
            this.searchForm = {
              search_LIKE_name: '',
              search_LIKE_code: '',
              search_LIKE_legalPerson: '',
              search_LIKE_property: ''
            }
            this.getList({ pagination: this.serverPagination })
          },
          // 启用
          startSupplier: function() {
            if (this.selected.length > 0) {
              var that = this
              this.$q.dialog({
                title: '启用',
                message: '确认启用这些供应商吗',
                ok: {
                  label: '确认',
                  flat: true,
                  color: 'primary'
                },
                cancel: {
                  label: '取消',
                  flat: true,
                  color: 'primary'
                }
              })
              .then(function() {
                var _arr = []
                that.selected.map(function(item) {
                  if (item.vendor) {
                    _arr.push(item.vendor.id)
                  }
                })
                axios({
                  method: 'post',
                  url: '/manager/admin/vendor/enableOrDisable/1',
                  data: {
                    dataIds: _arr.join(',') + ','
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: data.message,
                      type: 'positive',
                      icon: 'done',
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.message,
                      icon: 'error_outline',
                      type: 'negative',
                      position: 'top-right'
                    })
                  }
                  that.selected = []
                  that.getList({
                    pagination: that.serverPagination
                  }, that.selectedTab)
                })
                .catch(function(err) {
                  console.log(err, '启用供应商时捕获异常！')
                })
              })
              .catch(function() {
              })
            } else {
              this.$q.notify({
                message: '请勾选您要启用的供应商',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 禁用
          stopSupplier: function() {
            if (this.selected.length > 0) {
              var that = this
              this.$q.dialog({
                title: '禁用',
                message: '确认禁用这些供应商吗',
                ok: {
                  label: '确认',
                  flat: true,
                  color: 'primary'
                },
                cancel: {
                  label: '取消',
                  flat: true,
                  color: 'primary'
                }
              })
              .then(function() {
                var _arr = []
                that.selected.map(function(item) {
                  if (item.vendor) {
                    _arr.push(item.vendor.id)
                  }
                })
                axios({
                  method: 'post',
                  url: '/manager/admin/vendor/enableOrDisable/0',
                  data: {
                    dataIds: _arr.join(',') + ','
                  }
                })
                .then(function(data) {
                  console.log(data)
                  if (data.success) {
                    that.$q.notify({
                      message: data.message,
                      type: 'positive',
                      icon: 'done',
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.message,
                      icon: 'error_outline',
                      type: 'negative',
                      position: 'top-right'
                    })
                  }
                  that.selected = []
                  that.getList({
                    pagination: that.serverPagination
                  }, that.selectedTab)
                })
                .catch(function(err) {
                  console.log(err, '禁用供应商时捕获异常！')
                })
              })
              .catch(function() {
              })
            } else {
              this.$q.notify({
                message: '请勾选您要禁用的供应商',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 获取科目组数据
          getSubjectGroupData: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/dictGroup/getDictItemSelect/SUBJECT'
            })
            .then(function(data) {
                var _arr = []
                data.map(function(item) {
                  var _obj = {}
                  _obj.label = item.name
                  _obj.value = item.id
                  _arr.push(_obj)
                })
                that.subjectGroupOptions = _arr
            })
            .catch(function(err) {
              console.log(err, '获取科目组数据时捕获异常')
            })
          },
          // 根据科目组 获取 编码规则
          getCodeRuleData: function(subject) {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/dictGroup/getSubjectCodeRuleRel/' + subject
            })
            .then(function(data) {
                var _arr = []
                data.map(function(item) {
                  var _obj = {}
                  _obj.label = item.name
                  _obj.value = item.name
                  _arr.push(_obj)
                })
                that.codeRuleOptions = _arr
            })
            .catch(function(err) {
              console.log(err, '获取科目组数据时捕获异常')
            })
          },
          // 申请供应商编码 生成
          requestSupplierCode: function() {
            // if (this.selected.length > 0) {
              this.requestSupplierCodeModal = true
            // } else {
            //   this.$q.notify({
            //     message: '请您先勾选需要申请编码的供应商',
            //     type: 'warning',
            //     icon: 'warning',
            //     position: 'top-right'
            //   })
            // }
          },
          saveRequestHandler: function() {
            this.$v.requestSupplierCodeForm.$touch()
            if (!this.$v.requestSupplierCodeForm.$error) {
              this.btnLoading = true
              var that = this
              axios({
                method: 'post',
                url: '', // TODO: 暂无接口
                data: {
                  ids: this.selected.join(','),
                  subjectGroupId: this.requestSupplierCodeForm.subjectGroupId,
                  codeRule: this.requestSupplierCodeForm.codeRule
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: that.$t('申请成功'),
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else if (data.statusCode == 201) {
                  that.$q.notify({
                    message: '部分申请成功!失败条数：' + data.rowsStatusCode.length,
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.requestSupplierCodeModal = false
                that.getList({
                  pagination: this.serverPagination
                })
              })
              .catch(function(err) {
                console.log(err, '申请供应商编码时捕获到异常')
              })
            }
          },
          // 申请供应商编码 其他系统获取
          requestSupplierCodeFrom: function() {
            if (this.selected.length > 0) {
              var that = this
              this.$q.dialog({
                title: '申请正式编码',
                message: '确认从其它系统获取正式编码吗？',
                ok: {
                  label: '确认',
                  flat: true,
                  color: 'primary'
                },
                cancel: {
                  label: '取消',
                  flat: true,
                  color: 'primary'
                }
              })
              .then(function() {
                var _arr = []
                that.selected.map(function(item) {
                  _arr.push(item.id)
                })
                axios({
                  method: 'post',
                  url: '', // TODO: 暂无接口
                  data: {
                    dataIds: _arr.join(',')
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: data.message,
                      type: 'positive',
                      icon: 'done',
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.message,
                      icon: 'error_outline',
                      type: 'negative',
                      position: 'top-right'
                    })
                  }
                })
                .catch(function(err) {
                  console.log(err, '申请正式编码时捕获异常！')
                })
              })
              .catch(function() {
              })
            } else {
              this.$q.notify({
                message: '请勾选您要申请正式编码的供应商',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 下发
          supplierDispatch: function() {
            if (this.selected.length > 0) {
              var that = this
              this.$q.dialog({
                title: '下发其他系统',
                message: '确认下发其他系统吗？',
                ok: {
                  label: '确认',
                  flat: true,
                  color: 'primary'
                },
                cancel: {
                  label: '取消',
                  flat: true,
                  color: 'primary'
                }
              })
              .then(function() {
                var _arr = []
                that.selected.map(function(item) {
                  _arr.push(item.id)
                })
                axios({
                  method: 'post',
                  url: '/manager/admin/vendor/sysVendor', // TODO: 暂无接口
                  data: {
                    dataIds: _arr.join(',')
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: data.message,
                      type: 'positive',
                      icon: 'done',
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.message,
                      icon: 'error_outline',
                      type: 'negative',
                      position: 'top-right'
                    })
                  }
                })
                .catch(function(err) {
                  console.log(err, '下发其他系统时捕获异常！')
                })
              })
              .catch(function() {
              })
            } else {
              this.$q.notify({
                message: '请勾选您要下发其他系统的供应商',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          goSupplierBaseInfoLook: function(orgId, id) {
            window.location.href = 'supplierBaseInfoLook.html?orgId=' + orgId + '&id=' + id
          },
        }
      })
    </script>
  </body>
</html>
